package com.wyzz.hr.dao.impl;

import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import com.wyzz.hr.dao.RoleDao;
import com.wyzz.hr.hibernate.impl.HibernateUtil;
import com.wyzz.hr.pojo.Role;

public class RoleDaoImpl extends HibernateUtil implements RoleDao {

	public RoleDaoImpl() {
	}

	public Role findRoleByName(String roleName) {
		Session session = getSession();
		return (Role) session.createCriteria(com.wyzz.hr.pojo.Role.class).add(
				Restrictions.eq("roleName", roleName)).uniqueResult();
	}

	public boolean findRoleBySortid(int sortId) {
		Session session = getSession();
		Role r = (Role) session.createCriteria(com.wyzz.hr.pojo.Role.class)
				.add(Restrictions.eq("roleSortId", Integer.valueOf(sortId)))
				.uniqueResult();
		return r != null;
	}
}
